package com.example.systemservice.feign.factory;

import com.example.systemservice.feign.RemoteUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);

    @Override
    public RemoteUserService create(Throwable cause) {

        return new RemoteUserService() {
            @Override
            public Object userInfo() {
                log.info("熔断机制介入");
                return "接口被熔断";
            }

        };
    }
}
